program main
integer a(80),p1,p2,p3,p4,u1,u2,k
logical m,s
read(*,*)n
m=.false.
do 10 while(.not.m)
    write(*,*)'input p1,p2,p3,p4'
    read(*,*)p1,p2,p3,p4
    m=s(p1,p2,p3,p4)
10 continue
do 20 i=1,n
    a(i)=i
    !real(sui())
20 continue
write(*,*)(a(i),i=1,n)
u1=p2-p1
u2=p4-p3
do,h=0,u2
    do,j=0,(p3-p1-1)
        k=a(p3+h-j)
        a(P3+h-j)=a(p3+h-j-1)
        a(p3+h-j-1)=k
end do
end do
do,h=0,u1
    do,j=0,(p4-p1-u2-1)
        k=a(p1+u2+h-j)
        a(p1+u2+h-j)=a(p1+u2+h-j+1)
        a(p1+u2+h-j+1)=k
end do
end do
write(*,*)(a(i),i=1,n)
end


function s(p1,p2,p3,p4)
    integer p1,p2,p3,p4,h
    logical s
    h=1
    if(h.LE.p1.and.p2.GT.p1.and.p3.GT.p2.and.p4.GT.p3.and.p4.LT.20)then
        s=.true.
    else
        s=.false.
    end if
end function
function sui()
real :: x
call random_seed ()
call random_number (x)
sui=x*100
end function

